package ru.pb.global.data.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class InventoryInfo
{
	private List<ItemInfo> _itemInfo;

	public InventoryInfo()
	{}

	public void addItemInfo(ItemInfo info)
	{
		if(_itemInfo == null)
			_itemInfo = new ArrayList<ItemInfo>();
		_itemInfo.add(info);
	}

	public List<ItemInfo> getItemInfos()
	{
		if(_itemInfo == null)
			return Collections.emptyList();
		return _itemInfo;
	}

	public int getEquippedItemIdByEquipedSlot(int equippedSlotId)
	{
		for(ItemInfo ii : getItemInfos())
			if(ii.getEquippedSlot() == equippedSlotId && ii.getEquippedLocation() == 1)
				return ii.getItemId();
		return 0;
	}

	public List<ItemInfo> getAllArmors()
	{
		List<ItemInfo> temp = new ArrayList<ItemInfo>();
		for(ItemInfo ii : getItemInfos())
			if(ii.getItemType() == 0)
				temp.add(ii);
		return temp;
	}

	public List<ItemInfo> getAllWeapons()
	{
		List<ItemInfo> temp = new ArrayList<ItemInfo>();
		for(ItemInfo ii : getItemInfos())
			if(ii.getItemType() == 1)
				temp.add(ii);
		return temp;
	}

	public List<ItemInfo> getAllCupons()
	{
		List<ItemInfo> temp = new ArrayList<ItemInfo>();
		for(ItemInfo ii : getItemInfos())
			if(ii.getItemType() == 2)
				temp.add(ii);
		return temp;
	}

	public List<ItemInfo> getAllEtcItems()
	{
		List<ItemInfo> temp = new ArrayList<ItemInfo>();
		for(ItemInfo ii : getItemInfos())
			if(ii.getItemType() == 3)
				temp.add(ii);
		return temp;
	}
}